using MicroMsg.Plugin.Sns.Scene;
using MicroMsg.Storage;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace MicroMsg.UI.UserContrl
{
	public class MMHttpImg : SnsHttpImgCtrlBase
	{
		private const string TAG = "MMHttpImg";
		private bool mBIsImageShown;
		private bool mBIsEnableTouchEffect = true;
		internal Image imgContent;
		internal Grid gridCover;
		private bool _contentLoaded;
		public event MMStandardUIEvent Clicked;
		public MMHttpImg()
		{
			this.InitializeComponent();
		}
		public void ShowImg()
		{
			if (this.mBIsImageShown)
			{
				return;
			}
			this.mBIsImageShown = true;
			snsMediaDownloadInfo objReqInfo = new snsMediaDownloadInfo
			{
				snsObjID = base.ObjMediaInfo.nID,
				string_0 = base.ObjMediaInfo.strThumb,
				urlType = (SnsUrlType)base.ObjMediaInfo.nThumbType,
				priority = SnsPriority.LOW
			};
			base.StartRequest(objReqInfo, true);
		}
		protected override void ObjectCome(object object_0)
		{
			if (object_0 != null && object_0 is snsMediaDownloadInfo)
			{
				snsMediaDownloadInfo snsMediaDownloadInfo = object_0 as snsMediaDownloadInfo;
				if (snsMediaDownloadInfo.object_0 != null && snsMediaDownloadInfo.object_0 is BitmapImage)
				{
					(snsMediaDownloadInfo.object_0 as BitmapImage).set_CreateOptions(2);
					this.imgContent.set_Source(snsMediaDownloadInfo.object_0 as BitmapImage);
				}
				return;
			}
		}
		protected override void MediaInfoChanged(TloMedia mediaInfo)
		{
			this.imgContent.set_Source(null);
			if (base.ObjMediaInfo == null)
			{
				base.StopRequest();
				return;
			}
			this.mBIsImageShown = false;
			this.ShowImg();
		}
		private void ClickEffectGrid_mClicked(object sender, object object_0)
		{
			if (this.Clicked != null)
			{
				this.Clicked(sender, object_0);
			}
		}
		public void DisableTouchEffect()
		{
			this.mBIsEnableTouchEffect = false;
		}
		public void EnableTouchEffect()
		{
			this.mBIsEnableTouchEffect = true;
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/CommonUseControl/MMHttpImg.xaml", 2));
			this.imgContent = (Image)base.FindName("imgContent");
			this.gridCover = (Grid)base.FindName("gridCover");
		}
	}
}
